package top.college.jjb;

import java.awt.BorderLayout;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.swing.BoxLayout;

import TOP_Version1.Top_JDBC_Connection;

import top.college.dao.JDBC_ConnClose;
// 학생 정보 조회
public class studentinfo extends JPanel {
	private JTextField tt;
	private JTextField tt1;
	private JTextField tt2;
	private JTextField tt3;
	private JTextField tt4;
	private static Connection conn;
	private static PreparedStatement pstmt;
	private static ResultSet rs;
	

	public studentinfo() {
		uptop();
		upcenter();
		updown();
		
		
		
	}


private void uptop(){
	new JPanel();
	setLayout(new BorderLayout(0, 0));
	JPanel infop = new JPanel();
	add(infop, BorderLayout.NORTH);
	
	JLabel infolab = new JLabel("학생 정보 조회");
	infop.add(infolab);
}
private void upcenter(){
}
private void updown(){
	
	JPanel panel = new JPanel();
	add(panel, BorderLayout.WEST);
	panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
	
	JLabel lblNewLabel = new JLabel("학번");
	panel.add(lblNewLabel);
	
	JLabel label_1 = new JLabel("이름");
	label_1.setAlignmentY(1.0f);
	panel.add(label_1);
	
	JLabel label_2 = new JLabel("전화번호");
	panel.add(label_2);
	
	JLabel lblNewLabel_1 = new JLabel("주소");
	panel.add(lblNewLabel_1);
	
	JLabel lblNewLabel_2 = new JLabel("학과번호");
	panel.add(lblNewLabel_2);
	
	JPanel panel_1 = new JPanel();
	panel_1.setPreferredSize(new Dimension(200, 10));
	add(panel_1, BorderLayout.EAST);
	
	JPanel panel_2 = new JPanel();
	add(panel_2, BorderLayout.CENTER);
	
	tt = new JTextField();
	tt.setColumns(10);
	panel_2.add(tt);
	
	tt1 = new JTextField();
	tt1.setColumns(10);
	panel_2.add(tt1);
	
	tt2 = new JTextField();
	tt2.setColumns(10);
	panel_2.add(tt2);
	
	tt3 = new JTextField();
	tt3.setColumns(10);
	panel_2.add(tt3);
	
	tt4 = new JTextField();
	panel_2.add(tt4);
	tt4.setColumns(10);
	
	JPanel panel_3 = new JPanel();
	add(panel_3, BorderLayout.SOUTH);
	
	JButton btnNewButton = new JButton("확인");
	btnNewButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			StudentVO sv = new  StudentVO();
			sv.setStd_no(tt.getText());
			try{
				conn = JDBC_ConnClose.openDataBase();
				pstmt = conn.prepareStatement(JDBC_SQL_1.StudentSelectNoSQL);
				pstmt.setString( 1, sv.getStd_no());
				pstmt.executeUpdate();
				System.out.println("입력이 완료되었습니다");
			}catch(Exception ex){
				ex.printStackTrace();	
			}finally{
				Top_JDBC_Connection.closeDataBase(conn, pstmt, rs);
			}
		}
		
	});
	panel_3.add(btnNewButton);
}

}
